var names = [
	"曾镇洋", "刘炫均", "黎竹", "黄文凯", "伍俊宇", "刘文浩", "龚梓鑫", "吴润宇", "李科", "丁杨",
	"王惠斌", "张海涛", "郑锦沛", "曾海锋", "闻演斌", "刘东霖", "刘朕威", "宋天程", "卓锦源", "汪思宇",
	"肖润杰", "徐睿", "周博", "王博志", "余宇凡", "钟一鸣", "吴梓霖", "徐志敬", "王聿晗", "曾航",
	"林奕杰", "温德灿", "黄明杰", "徐雍琳", "刘永佳", "曹淼", "李悦", "李欣宜", "刘颖芳", "黎羽路",
	"蒋恋", "杨玉琪", "卢泳仪", "赖冰慧", "周照", "卢琳", "陈欣榆", "吴雨昊", "张惠婷", "张子晴"
];

var drawname;
var index = -1;
var time;
var flag = 1;

function btnOnclick() {
	if (flag % 2 == 1) {
		begin();
		document.getElementById("BTN").value = "按A暂停";
	}
	if (flag % 2 == 0) {
		end();
		document.getElementById("BTN").value = "按A开始";
	}
	flag++;
}

function begin() {
	document.getElementById("BTN").disabled = false;
	draw();
}

function draw() {
	if (names.length > 0) {
		index = Math.floor(Math.random() * 1000 % names.length);
		drawname = names[index];
		document.getElementById("result").innerHTML = drawname;

		time = window.setTimeout(draw, 2);
	} else {
		document.getElementById("result").innerHTML = "~请刷新网页~";
	}
}

function speech() {
	index++;
	var url = "./broadcast/voice/" + index + ".mp3";
	new Audio(url).play();
}

function end() {
	speech();
	window.clearTimeout(time);
	document.getElementById("BTN").disabled = false;
	names.splice(index, -1);
}